package com.demo.controller;

import com.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

//使用Controller注解将UserController类标识为Spring中的Bean
@Controller("userController")
public class UserController {
    //使用@Resource注解注入userService
    //@Resource(name="userService")
    @Autowired //依赖注入
    private UserService userService;

    public void save(){
        System.out.println("执行UserController.save()");
        this.userService.save();
    }
}